package com.example.guet_assistant.controller;
import com.example.guet_assistant.domain.dto.MessageDTO;
import com.example.guet_assistant.domain.vo.MessageVO;
import com.example.guet_assistant.domain.vo.ReturnMessageVO;
import com.example.guet_assistant.pojo.entity.Message;
import com.example.guet_assistant.pojo.entity.MessageType;
import com.example.guet_assistant.result.Result;
import com.example.guet_assistant.service.MessageService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author author
 * @since 2024-11-12
 */
@Tag(name="消息管理接口")
@RestController
@RequestMapping("/message")
public class MessageController {
    @Autowired
    private MessageService messageService;

    @Operation(summary = "获取天气信息")
    @GetMapping("/weather")
    public Result getWeather() throws Exception{
         return  messageService.getWeather();
    }



    @Operation(summary = "管理员发布信息")
    @PostMapping("/postMessage")
    public Result postMessage(@RequestBody MessageVO messageVO) throws Exception{
        return Result.success(messageService.saveBatch(messageService.publishMessage(messageVO)));
    }

    @Operation(summary = "获取消息类型")
    @GetMapping("/getMessageType")
    public Result<List<String>> getMessageType() throws Exception {
        return messageService.getMessageType();
    }

    @Operation(summary = "用户获取消息标题列表")
    @GetMapping("/getTitleList")
    public Result<List<ReturnMessageVO>> getTitleList(String userId, String type) throws Exception{
        return messageService.getTitleList(userId, type);
    }

    @Operation(summary = "用户获取消息详情")
    @GetMapping("/getMessageList")
    public Result<List<String>> getMessageList(Integer id, String title) throws Exception{
        return messageService.getMessageList(id, title);
    }

}
